@extends('layout.zhongxin')
@section('title', '我的订单')
@section('zhong')
  <div class="mt">
    <h3>我的订单</h3>
    <div class="extra-r">
      <a href="#" target="_self" clstag="homepage|keycount|home2013|Homeckddk">查看全部订单</a>
    </div>
  </div>
  <table class="mc" width="80%" border="1" cellpadding="5" cellspacing="1" bgcolor="#dddddd" style="text-align:center">
    <tbody>
      <tr align="center">
      <td bgcolor="#ffffff">订单号</td>
      <td bgcolor="#ffffff">下单时间</td>
      <td bgcolor="#ffffff">订单总金额</td>
      <td bgcolor="#ffffff">订单状态</td>
      <td bgcolor="#ffffff">操作</td>
      </tr>
      @foreach($dat as $k=>$v)

      <tr>
        <td class="  sorting_1">{{$v['order_code']}}</td>
        <td class=" ">{{$v['created_at']}}</td>
        <td class=" ">{{$v['total']}}</td>
        <td class=" ">{{str_replace([1,2,3,4,5,6],['已下单','已付款','已发货','已收货','已退单','订单已完成'],$v['status'])}}</td>
        <td class=" ">
        <a href="" class="delete" aid="{{$v['id']}}">取消订单|</a>
        <a href="/geren/xiangq?id={{$v['id']}}">订单详情</a>
        </td>
      </tr>
      @endforeach
    </tbody>
  </table>
@endsection
@section('xin')
<script type="text/javascript">
//如果要发post请求 csrf保护
    // <meta name="csrf-token" content="{{ csrf_token() }}">
    //在发送ajax请求前 ,设置全局配置
//     $.ajaxSetup({
//         headers: {
//             'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
//         }
// });   
    $('.delete').click(function(){
        var id = $(this).attr('aid');
        // alert(id);

        var td = $(this);
        //发送ajax
        $.get('{{url("/orders/delete")}}',{id:id},function(data){
            if(data == 1){
                td.parents('tr').remove();
            }
            // alert(data);
        })
        return false;
    })
</script>
@endsection
